import {createStore} from 'redux';
import reducers from './reducers';
// import {addTodo, setVisibilityFilter, toggleTodo, VisibilityFilters} from "./actions";

const store = createStore(reducers);

// console.log(store.getState());

// 注册监听器，监听state变化
// 返回值可以用来注销监听器
let unsubscribe = store.subscribe(() => {
  console.log(store.getState());
});

// store.dispatch(addTodo('Learn redux'));
// store.dispatch(addTodo('Learn reducers'));
// store.dispatch(addTodo('Learn actions'));
// store.dispatch(addTodo('Learn store'));

// store.dispatch(toggleTodo(1));
// store.dispatch(toggleTodo(2));

// store.dispatch(setVisibilityFilter(VisibilityFilters.SHOW_COMPLETED));

// 注销监听器
// unsubscribe();

export default store
